<template>
	<view>
		<view class="text-center my-size bg-black" @longpress="showModal" data-target="Image" v-if="toCount<=3.50">
			<view class="text-xl">{{notes}}</view>
		</view>

		<view class="text-center my-size bg-cyan light" @longpress="showModal" data-target="Image" v-else>
			<view class="text-xl">haaaaaah</view>
		</view>

		<view class="cu-modal" :class="modalName=='Image'?'show':''">
			<view class="cu-dialog">
				<view class="bg-img" style="background-image: url('../../static/miaomiao.gif');height:35vh"></view>
				<view class="cu-bar bg-white">
					<view class="action margin-0 flex-sub" @tap="hideModal">取消</view>
					<view class="action margin-0 flex-sub solid-left text-red" @tap="toLog">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				PageCur: 'basics',
				Days: '0',
				lastTime: 0,
				presentTime: 0,
				numbers: 0,
				notes: "貌似时间还没有到啊",

				modalName: null,
			}
		},
		mounted() {
			var UdateNow = new Date();
			var Udate2020 = new Date('2020-06-07');
			var date = new Date(Udate2020 - UdateNow)

			var time = Math.ceil(date / (1000 * 60 * 60 * 24)); //1000 * 60 * 60 * 24一天的秒数

			this.Days = time;

			console.log(new Date(uni.getStorageSync('last_time')))
		},
		computed: {
			toCount() {
				let lastTime = new Date(uni.getStorageSync('last_time')).getTime();
				let presentTime = new Date().getTime() - lastTime;
				let numbers = presentTime / (24 * 60 * 60 * 1000).toFixed(2);
				return numbers
			}
		},
		methods: {
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null;
				// #ifdef APP-PLUS
				plus.fingerprint.cancel();
				// #endif 
			},
			toLog() {
				this.fingerprint();
			},
			fingerprint: function() {
				var that = this;
				// #ifdef APP-PLUS
				plus.fingerprint.authenticate(function() {
					plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
					uni.setStorageSync('last_time', new Date().getTime());

					console.log(that.modalName);
					console.log(that.lastTime);
					console.log(that.presentTime);

					that.notes = "haaah,又续了一波";
					that.hideModal();
					uni.showToast();
				}, function(e) {
					switch (e.code) {
						case e.AUTHENTICATE_MISMATCH:
							plus.nativeUI.toast('指纹匹配失败，请重新输入');
							break;
						case e.AUTHENTICATE_OVERLIMIT:
							plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
							plus.nativeUI.alert('指纹识别失败次数超出限制，请使用其它方式进行认证');
							break;
						case e.CANCEL:
							plus.nativeUI.toast('已取消识别');
							break;
						default:
							plus.nativeUI.closeWaiting(); //兼容Android平台关闭等待框
							plus.nativeUI.alert('指纹识别失败，请重试');
							break;
					}
				});
				// #endif 
			}
		}
	}
</script>

<style>
	page {
		background: white;
	}

	.my-size {
		display: table-cell;
		vertical-align: middle;
		width: 100vw;
		height: 100vh;
	}
</style>
